<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [formGroup]="formGroup" [lvLabelColon]="false" class="formGroup mgt-10">
    <lv-form-item>
        <lv-form-label>
            {{filterLabel}}
        </lv-form-label>
        <lv-form-control>
            <lv-switch formControlName="enableFilter"></lv-switch>
            <div *ngIf="formGroup.value.enableFilter" class="mgt-8">
                <lv-form-item>
                    <lv-form-label>
                        {{'protection_filter_type_label' | i18n}}
                    </lv-form-label>
                    <lv-form-control>
                        <lv-select formControlName="type" [lvOptions]='typeOptions' lvValueKey='value'>
                        </lv-select>
                    </lv-form-control>
                </lv-form-item>
                <ng-container
                    *ngIf="formGroup.value.type === dataMap.resourceFilterType.mix.value || formGroup.value.type === dataMap.resourceFilterType.include.value">
                    <lv-form-item>
                        <lv-form-label>
                            {{'protection_include_label' | i18n}}
                            <i lv-icon="aui-icon-help"
                                lv-tooltip="{{'protection_include_tips_label' | i18n:[filterType]}}"
                                lvTooltipTheme="light" class="configform-constraint" lvColorState="true"></i>
                        </lv-form-label>
                        <lv-form-control [lvErrorTip]="filterErrorTip">
                            <lv-input-tag formControlName='include' [lvPlaceholder]="filterTipLabel"></lv-input-tag>
                        </lv-form-control>
                    </lv-form-item>
                </ng-container>
                <ng-container *ngIf="formGroup.value.type === dataMap.resourceFilterType.mix.value">
                    <lv-form-item>
                        <lv-form-label>
                            {{'protection_and_exclude_label' | i18n}}
                            <i lv-icon="aui-icon-help"
                                lv-tooltip="{{'protection_include_tips_label' | i18n:[filterType]}}"
                                lvTooltipTheme="light" class="configform-constraint" lvColorState="true"></i>
                        </lv-form-label>
                        <lv-form-control [lvErrorTip]="filterErrorTip">
                            <lv-input-tag formControlName='andExclude' [lvPlaceholder]="filterTipLabel"></lv-input-tag>
                        </lv-form-control>
                    </lv-form-item>
                </ng-container>
                <ng-container *ngIf="formGroup.value.type === dataMap.resourceFilterType.exclude.value">
                    <lv-form-item>
                        <lv-form-label>
                            {{'common_exclude_label' | i18n}}
                            <i lv-icon="aui-icon-help"
                                lv-tooltip="{{'protection_include_tips_label' | i18n:[filterType]}}"
                                lvTooltipTheme="light" class="configform-constraint" lvColorState="true"></i>
                        </lv-form-label>
                        <lv-form-control [lvErrorTip]="filterErrorTip">
                            <lv-input-tag formControlName='exclude' [lvPlaceholder]="filterTipLabel"></lv-input-tag>
                        </lv-form-control>
                    </lv-form-item>
                </ng-container>
            </div>
        </lv-form-control>
    </lv-form-item>
    <!-- 虚拟机tag过滤 -->
    <ng-container *ngIf="isVmware">
        <lv-form-item>
            <lv-form-label>
                {{'protection_tag_filter_label' | i18n}}
            </lv-form-label>
            <lv-form-control>
                <lv-switch formControlName="enableTagFilter"></lv-switch>
                <div *ngIf="formGroup.value.enableTagFilter" class="mgt-8">
                    <lv-form-item>
                        <lv-form-label>
                            {{'protection_filter_type_label' | i18n}}
                        </lv-form-label>
                        <lv-form-control>
                            <lv-select formControlName="tagType" [lvOptions]='typeOptions' lvValueKey='value'>
                            </lv-select>
                        </lv-form-control>
                    </lv-form-item>
                    <ng-container
                        *ngIf="formGroup.value.tagType === dataMap.resourceFilterType.mix.value || formGroup.value.tagType === dataMap.resourceFilterType.include.value">
                        <lv-form-item>
                            <lv-form-label>
                                {{'protection_include_label' | i18n}}
                                <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_tag_filter_tips_label' | i18n}}"
                                    lvTooltipTheme="light" class="configform-constraint" lvColorState="true"></i>
                            </lv-form-label>
                            <lv-form-control [lvErrorTip]="filterErrorTip">
                                <lv-input-tag formControlName='includeTag'
                                    lvPlaceholder="{{'protection_vm_tag_placeholder_label' | i18n}}"></lv-input-tag>
                            </lv-form-control>
                        </lv-form-item>
                    </ng-container>
                    <ng-container *ngIf="formGroup.value.tagType === dataMap.resourceFilterType.mix.value">
                        <lv-form-item>
                            <lv-form-label>
                                {{'protection_and_exclude_label' | i18n}}
                                <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_tag_filter_tips_label' | i18n}}"
                                    lvTooltipTheme="light" class="configform-constraint" lvColorState="true"></i>
                            </lv-form-label>
                            <lv-form-control [lvErrorTip]="filterErrorTip">
                                <lv-input-tag formControlName='andExcludeTag'
                                    lvPlaceholder="{{'protection_vm_tag_placeholder_label' | i18n}}"></lv-input-tag>
                            </lv-form-control>
                        </lv-form-item>
                    </ng-container>
                    <ng-container *ngIf="formGroup.value.tagType === dataMap.resourceFilterType.exclude.value">
                        <lv-form-item>
                            <lv-form-label>
                                {{'common_exclude_label' | i18n}}
                                <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_tag_filter_tips_label' | i18n}}"
                                    lvTooltipTheme="light" class="configform-constraint" lvColorState="true"></i>
                            </lv-form-label>
                            <lv-form-control [lvErrorTip]="filterErrorTip">
                                <lv-input-tag formControlName='excludeTag'
                                    lvPlaceholder="{{'protection_vm_tag_placeholder_label' | i18n}}"></lv-input-tag>
                            </lv-form-control>
                        </lv-form-item>
                    </ng-container>
                </div>
            </lv-form-control>
        </lv-form-item>
    </ng-container>
</lv-form>